using System;

namespace WindowsControlers
{
	/**
	 * 完全路径实现窗体
	 * 给窗体添加label 和 button
	 */

	public class Form03
	{
		private System.Windows.Forms.Form form1 = null;
		private System.Windows.Forms.Label label1 = null;
		private System.Windows.Forms.Button button1 = null;
		private System.Windows.Forms.Button button2 = null;

		public Form03()
		{
			this.form1 = new System.Windows.Forms.Form() {
				Text = "Hello,Form",

				//Size属性改变窗体大小
				Size = new System.Drawing.Size(400, 300),
				//Border = WindowStyle.SingleDialog,

				//Location属性替换Top和Left改变窗体位置
				Location = new System.Drawing.Point(100, 50),

				Icon = new System.Drawing.Icon("D:\\UI\\dailybox\\logo.ico"),
			};

			this.label1 = new System.Windows.Forms.Label() {
				Width = 300,
				Left = 50,
				Top = 20,
				Text = "Label1",
			};

			this.button1 = new System.Windows.Forms.Button() {
				Width = 80,
				Top = 80,
				Left = 50,
				Text = "Button1",
			};
			
			this.button2 = new System.Windows.Forms.Button() {
				Width = 80,
				Top = 80,
				Left = 200,
				Text = "Button2",
			};
			
			//给按钮添加事件
			this.button1.Click += new System.EventHandler(this.Button1_Click);

			//内联事件
			this.button2.Click += (sender, e) => {
				System.Windows.Forms.MessageBox.Show("Hello, Clicked Button2");
			};

			form1.Controls.Add(label1);
			form1.Controls.Add(button1);
			form1.Controls.Add(button2);

			System.Windows.Forms.Application.Run(form1);
		}

		public void Button1_Click(object sender, System.EventArgs e)
		{
			this.label1.Text = "Hello, Drawing Controlers";
		}

		public static void Main(string[] args)
		{
			new Form03();
		}
	}
}